#ifndef file_h
#define file_h

// this header needs
// #include "../wchar/string/string.h"
// #include "../number/bits.h"
// #include "../number/int.h"
// ^ all those are already included when including float.h
#include "../number/float.h"

// file structure
typedef struct {
  owl_str * path;
  owl_str * data;
} owl_file;

// basic functions
owl_umax owl_get_file_size(owl_byte * file_path); // used internally
owl_bool owl_check_file_pointer(owl_byte * src, owl_umax size);
owl_bool owl_check_file_members(owl_str * path, owl_str * data);
owl_bool owl_check_file_all(owl_file * f, owl_umax size);
owl_file * owl_create_file(owl_byte * file_path, owl_umax path_size,
                           owl_wchar_enc path_enc, owl_wchar_enc file_enc);
owl_umax owl_free_file(owl_file * file);
owl_umax owl_print_file(owl_byte * src, owl_umax size);
owl_char owl_comp_file(owl_byte * file1, owl_byte * file2);

// specific functions
owl_str * owl_get_file_ext(owl_file * file);
owl_str * owl_get_file_basepath(owl_file * file);
owl_str * owl_get_file_name(owl_file * file);
owl_byte * owl_insert_bytes_file(owl_file * file, owl_umax pos, owl_str * bytes);
owl_umax owl_remove_bytes_file(owl_file * file, owl_umax pos, owl_umax rm_size);
owl_bool owl_append_to_file(owl_file * file, owl_file * append);
owl_bool owl_save_file(owl_file * file, owl_str * path);

// get data from the file
owl_str * owl_get_str_file(owl_file * file, owl_umax pos, owl_umax size, owl_wchar_enc enc);
owl_int_op_result owl_get_ch_uint_file(owl_file * file, owl_umax pos, owl_wchar_enc enc);
owl_int_op_result owl_get_ch_sint_file(owl_file * file, owl_umax pos, owl_wchar_enc enc);
owl_float_op_result owl_get_ch_float_file(owl_file * file, owl_umax pos, owl_wchar_enc enc);
owl_int_op_result owl_get_enc_uint_file(owl_file * file, owl_umax pos, owl_umax left_pad, owl_umax num_bits);
owl_int_op_result owl_get_enc_std_uint_file(owl_file * file, owl_umax pos, 
                                            owl_umax num_bits, owl_endian endian);
owl_int_op_result owl_get_enc_sint_file(owl_file * file, owl_umax pos, owl_umax left_pad, owl_umax num_bits);
owl_int_op_result owl_get_enc_std_sint_file(owl_file * file, owl_umax pos,
                                            owl_umax num_bits, owl_endian endian);
owl_float_op_result owl_get_enc_float_file(owl_file * file, owl_umax pos, owl_umax left_pad, owl_umax num_bits);
owl_float_op_result owl_get_enc_std_float_file(owl_file * file, owl_umax pos,
                                               owl_umax num_bits, owl_endian endian);

#include "file.c"

#endif // file_h
